package com.htgd.gardenexpo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.htgd.gardenexpo.entity.GeConIntegralDeduction;
import com.htgd.gardenexpo.dao.GeConIntegralDeductionDao;
import com.htgd.gardenexpo.entity.GeConIntegralGet;
import com.htgd.gardenexpo.page.IntegralDeductionQuery;
import com.htgd.gardenexpo.service.GeConIntegralDeductionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 积分获抵扣设置 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-06-21
 */
@Service
public class GeConIntegralDeductionServiceImpl extends ServiceImpl<GeConIntegralDeductionDao, GeConIntegralDeduction> implements GeConIntegralDeductionService {

    @Autowired
    private GeConIntegralDeductionDao geConIntegralDeductionDao;

    @Override
    public PageInfo<GeConIntegralDeduction> querylist(IntegralDeductionQuery integralDeductionQuery) {
        PageHelper.startPage(integralDeductionQuery.getPageNum(),integralDeductionQuery.getPageSize());
        List<GeConIntegralDeduction> list = geConIntegralDeductionDao.querylist(integralDeductionQuery);
        return new PageInfo<>(list);
    }

    @Override
    public void changeStatus(GeConIntegralDeduction geConIntegralDeduction) {
        lambdaUpdate().eq(GeConIntegralDeduction::getId,geConIntegralDeduction.getId())
                .set(GeConIntegralDeduction::getStatus,geConIntegralDeduction.getStatus())
                .update();

    }

    @Override
    public boolean getByCategoryIdExist(Integer categoryId) {
        return lambdaQuery().eq(GeConIntegralDeduction::getCategoryId,categoryId)
                .exists();
    }
}
